#pragma once

#include "pch.h"

struct TcpSocket
{
    uint64_t sock;

    struct Desc
    {
        const char *host;
        unsigned int port;

        unsigned int af = AF_INET;
        unsigned int type = SOCK_STREAM;
        unsigned int protocol = IPPROTO_TCP;

        unsigned int sinFamily = AF_INET;
    };

    bool Create(TcpSocket::Desc desc);

    void Close();

    template <typename T>
    int Recv(T &t)
    {
        return recv(sock, (char *)&t, sizeof(T), 0);
    }
    template <typename T>
    int Send(const T &t)
    {
        return send(sock, (const char *)&t, sizeof(T), 0);
    }
};